<?php 
use solideagle\utilities\SuperEntities;
?>
<script>

	$(function(){

		var users = $.parseJSON(<?php echo "'" . $this->users . "'" ?>);
		var manageTemplate = <?php echo $this->manageTemplate ?>;
		
		if(users.length == 0 && !manageTemplate)
		{
			alert("Geen gebruikers geselecteerd");
			return;
		}

   		$('#myModal').modal('show');
   		$("#deleteadsure").hide();
                $("#deletesssure").hide();
                $("#deletegappsure").hide(); 
                
                if ($("#createAdHomedir").is(":checked")) { 
                    $("#createAdHomedir").trigger('click').attr('checked','checked');
                }

                if ($("#createUpDownFolders").is(":checked")) { 
                    $("#createUpDownFolders").trigger('click').attr('checked','checked');
                }
                
                if ($("#moveAdHomedir").is(":checked")) { 
                    $("#moveAdHomedir").trigger('click').attr('checked','checked');
                }

		if(!manageTemplate)
		{
                    $("#blnDeleteAd").click(function(){
                            $("#deleteadsure").toggle();
                            $("#blnDeleteAdSure").removeAttr("checked");
                    });
                    $("#blnAdMultipleEnableDisable").click(function(){
                            $("#radioAdEnableAccounts").toggle();
                            $("#radioAdDisableAccounts").toggle();
                            $("#optionAdMultipleEnable").removeAttr("checked");
                            $("#optionAdMultipleDisable").removeAttr("checked");
                    });
                    $("#blnDeleteSs").click(function(){
                            $("#deletesssure").toggle();
                            $("#blnDeleteSsSure").removeAttr("checked");
                    });
                    $("#blnDeleteGapp").click(function(){
                            $("#deletegappsure").toggle();
                            $("#blnDeleteGappSure").removeAttr("checked");
                    });
                    
		}
	
		$("#formTasks").ajaxForm({
			beforeSubmit:  preventDoubleSubmit,
			data:  {"users[]":users},
			success: function(responseText, statusText, xhr, $form) { 
				if(responseText.length > 0)
				{
					alert(responseText);
					resetDoubleSubmit();
				}else{
					$('#myModal').modal('hide');
				}
	    } });
	});

	
</script>

<form
	class="form-horizontal"
	action="<?php echo $this->SE_path . "/usertasks/posttask" ?>"
	method="post"
	id="formTasks">

	<div
		class="hide SEsupermodal"
		id="myModal">
		<div>
			<div class="modal-header">
				<a
					class="close"
					data-dismiss="modal">×</a>
				<?php if($this->manageTemplate)
                {?>
				<h3 id="modaltitle">Beheer taak templates</h3>
				<?php
                }else{?>
				<h3 id="modaltitle">Taken uitvoeren</h3>
				<?php }?>
			</div>

			<div class="modal-body">
			
			<?php if($this->hasAccountsWithoutPassword)
					{
						?>
						<div class="alert alert-error">

						<strong>Opgelet!</strong> Er zijn accounts geselecteerd die geen of te een kort wachtwoord hebben!
					</div>
						<?php
					}?>
			

				<?php if($this->templatename != NULL || $this->manageTemplate)
                {?>
				<section id="tasktemplate">
					<div class="page-header">
						<h1>Taken templates</h1>
					</div>

					<div class="control-group">
						<label
							class="control-label"
							for="txtName">Naam template</label>
						<div class="controls">



							<input
								id="txtName"
								name="txtName"
								class="input-xlarge"
								type="text"
								<?php echo $this->manageTemplate ? "" : "readonly = 'readonly'" ?>
								value="<?php  echo $this->templatename  ?>">
						</div>
					</div>
					
					
					
					
					
					<?php if($this->manageTemplate && !$this->addtemplate)
							{ ?>

					<div class="alert">

						<strong>Opgelet!</strong> Een template hernoemen maakt een kloon aan
					</div>

					<?php }?>
				</section>
				<?php }?>

				<section id="activedirectory">
					<div class="page-header">
						<h1>
							Active directory <small>taken</small>
						</h1>
					</div>

					<div class="row">
                                            
                                            <div class="span12">
							<?php if ($this->multipleAccountsSelected || !$this->hasAdAccount || $this->manageTemplate)
                                                {?>
                                                    <div class="control-group">
                                                        <label class="control-label" for="createAdAccount">    
                                                                Account maken
                                                        </label>
                                                        <div class="controls">
                                                            <input
                                                                name="createAdAccount"
                                                                id="createAdAccount"
                                                                type="checkbox"
                                                                value="true"
                                                                <?php echo $this->defaults->createAdAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
                                                    
							<?php 
                                                }
                                                if ($this->multipleAccountsSelected || $this->hasAdAccount || $this->manageTemplate)
                            {?>
                                                    <div class="control-group">
                                                        <label class="control-label" for="blnDeleteAd">    
                                                                Account verwijderen
                                                        </label>
                                                        <div class="controls">
                                                            <input
                                                                name="deleteAdAccount"
                                                                id="blnDeleteAd"
                                                                type="checkbox"
                                                                value="false"
                                                                <?php echo $this->defaults->deleteAdAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
                                                    <div class="control-group error" id="deleteadsure">
                                                            <label
                                                                    class="control-label error"
                                                                    id="lbldeleteadsure" for="blndeleteadsure">
                                                                    Ja, ik ben zeker
                                                            </label>
                                                            <div class="controls">
                                                                <input
                                                                    id="blndeleteadsure"
                                                                    name="deleteAdAccountSure"
                                                                    type="checkbox"
                                                                    value="false">
                                                            </div>
                                                    </div>
							<?php
                            }
                            if ($this->multipleAccountsSelected || $this->hasAdAccountEnabled || $this->manageTemplate)
                           {?>
                                                    <div class="control-group">
							<label class="control-label" for="blnAdDisable">
								Account deactiveren
                                                        </label>
                                                        <div class="controls">
								<input
									name="disableAdAccount"
									id="blnAdDisable"
									type="checkbox"
									<?php echo $this->defaults->disableAdAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
							<?php
                           }
                           if($this->multipleAccountsSelected || !$this->hasAdAccountEnabled && $this->hasAdAccount || $this->manageTemplate)
                           {?>
							<div class="control-group">
                                                            <label class="control-label" for="blnAdEnable">
								Account activeren
                                                            </label>
                                                            <div class="controls">
								<input
									name="enableAdAccount"
									id="blnAdEnable"
									type="checkbox"
									<?php echo $this->defaults->enableAdAccount ? "checked='checked'" : "" ?>>
                                                            </div>
                                                        </div>
                                                
							<?php }?>
                                                        
                                                        <div class="control-group">
                                                            <label class="control-label" for="createAdHomedir">
                                                                Homedir maken
                                                            </label>
                                                            <div class="controls">
                                                                <input
                                                                        name="createAdHomedir"
                                                                        id="createAdHomedir"
                                                                        type="checkbox"
                                                                        data-toggle="collapse"
                                                                        data-target="#adHomeDirParams"
                                                                        value="true"
                                                                        <?php echo $this->defaults->createAdHomedir ? "checked='checked'" : "" ?>>
                                                            </div>
                                                        </div>
                                                
                                                        <div
                                                                id="adHomeDirParams"
                                                                class="collapse out">
                                                                <fieldset>
                                                                        <legend>Homefolder</legend>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="server">Server</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="server"
                                                                                                name="homefolderServer"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->homefolderServer); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>server.domain.example</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="serverpath">Homefolder pad op server</label>
                                                                                <div class="controls">
                                                                                        <div class="input-append">
                                                                                                <input
                                                                                                        id="serverpath"
                                                                                                        name="homefolderPath"
                                                                                                        class="input-xlarge"
                                                                                                        type="text"
                                                                                                        value="<?php echo SuperEntities::encode($this->defaults->homefolderPath); ?>">
                                                                                                <?php /*<span class="add-on">\leerkrachten\janssensj</span>*/ ?>
                                                                                                <p class="help-block ">
                                                                                                        <i>c:\pad\naar\homefolders    (eindigt op \homefolders)</i>
                                                                                                </p>
                                                                                        </div>
                                                                                </div>
                                                                        </div>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="scanpath">Scanpad op server</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="scanpath"
                                                                                                name="scanSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->scanSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\scanshare</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="wwwpath">WWW pad op server</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="wwwpath"
                                                                                                name="wwwSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->wwwSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\wwwshare</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>

                                                                </fieldset>

                                                        </div>

                                                        <div class="control-group">
                                                            <label class="control-label" for="createUpDownFolders">
                                                                Upload &amp; Downloadfolders maken
                                                            </label>
                                                            <div class="controls">
                                                                <input
                                                                        name="createUpDownFolders"
                                                                        id="createUpDownFolders"
                                                                        type="checkbox"
                                                                        data-toggle="collapse"
                                                                        data-target="#adUpDownParams"
                                                                        value="true"
                                                                        <?php echo $this->defaults->createUpDownFolders ? "checked='checked'" : "" ?>>
                                                            </div>
                                                        </div>

                                                        <div
                                                                id="adUpDownParams"
                                                                class="collapse out">
                                                                <fieldset>
                                                                        <legend>Upload &amp; Downloadfolders</legend>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="uploadpath">Uploadpad</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="uploadpath"
                                                                                                name="uploadSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->uploadSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\upload</i>
                                                                                        </p>
                                                                                </div>

                                                                                <label
                                                                                        class="control-label"
                                                                                        for="downloadpath">Downloadpad</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="downloadpath"
                                                                                                name="downloadSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->downloadSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\download</i>
                                                                                        </p>
                                                                                </div>

                                                                        </div>

                                                                </fieldset>

                                                        </div>

                                                        <div class="control-group">
                                                            <label class="control-label" for="moveAdHomedir">
                                                                Homedir verplaatsen
                                                            </label>
                                                            <div class="controls">
                                                                <input
                                                                        name="moveAdHomedir"
                                                                        id="moveAdHomedir"
                                                                        type="checkbox"
                                                                        data-toggle="collapse"
                                                                        data-target="#adMoveHomeDirParams"
                                                                        value="true"
                                                                        <?php echo $this->defaults->moveAdHomedir ? "checked='checked'" : "" ?>>
                                                            </div>
                                                        </div>
                                                
                                                         <div
                                                                id="adMoveHomeDirParams"
                                                                class="collapse out">
                                                                <fieldset>
                                                                        <legend>Homefolder verplaatsen</legend>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="server">Server</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="mServer"
                                                                                                name="moveHomefolderServer"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->moveHomefolderServer); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>server.domain.example</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="moveserverpath">Homefolder pad op server</label>
                                                                                <div class="controls">
                                                                                        <div class="input-append">
                                                                                                <input
                                                                                                        id="serverpath"
                                                                                                        name="moveHomefolderPath"
                                                                                                        class="input-xlarge"
                                                                                                        type="text"
                                                                                                        value="<?php echo SuperEntities::encode($this->defaults->moveHomefolderPath); ?>">
                                                                                                <span class="add-on">\janssensj</span>
                                                                                                <p class="help-block ">
                                                                                                        <i>c:\pad\naar\homefolders</i>
                                                                                                </p>
                                                                                        </div>
                                                                                </div>
                                                                        </div>
                                                                        
                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="movescanpath">Scanpad op server</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="movescanpath"
                                                                                                name="moveScanSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->moveScanSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\scanshare</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="movewwwpath">WWW pad op server</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="movewwwpath"
                                                                                                name="moveWwwSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->moveWwwSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\wwwshare</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>
                                                                        
                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="moveuploadpath">Uploadpad</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="moveuploadpath"
                                                                                                name="moveUploadSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->moveUploadSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\upload</i>
                                                                                        </p>
                                                                                </div>
                                                                        </div>

                                                                        <div class="control-group">
                                                                                <label
                                                                                        class="control-label"
                                                                                        for="movedownloadpath">Downloadpad</label>
                                                                                <div class="controls">
                                                                                        <input
                                                                                                id="movedownloadpath"
                                                                                                name="moveDownloadSharePath"
                                                                                                class="input-xlarge"
                                                                                                type="text"
                                                                                                value="<?php echo SuperEntities::encode($this->defaults->moveDownloadSharePath); ?>">
                                                                                        <p class="help-block ">
                                                                                                <i>c:\pad\naar\download</i>
                                                                                        </p>
                                                                                </div>

                                                                        </div>

                                                                </fieldset>

                                                         </div>
                                                
						</div>
                                        </div>
                                </section>
 
				<section id="smartschool">
					<div class="page-header">
						<h1>
							Smartschool <small>taken</small>
						</h1>
					</div>

					<div class="row"> 
                                            
                                            <div class="span12">
							<?php if ($this->multipleAccountsSelected || !$this->hasSsAccount || $this->manageTemplate)
                                                {?>
                                                    <div class="control-group">
                                                        <label class="control-label" for="createSsAccount">    
                                                                Account maken
                                                        </label>
                                                        <div class="controls">
                                                            <input
                                                                name="createSsAccount"
                                                                id="createSsAccount"
                                                                type="checkbox"
                                                                value="true"
                                                                <?php echo $this->defaults->createSsAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
                                                   
							<?php 
                                                }
                                                if ($this->multipleAccountsSelected || $this->hasSsAccount || $this->manageTemplate)
                            {?>
                                                    <div class="control-group">
                                                        <label class="control-label" for="blnDeleteSs">    
                                                                Account verwijderen
                                                        </label>
                                                        <div class="controls">
                                                            <input
                                                                name="deleteSsAccount"
                                                                id="blnDeleteSs"
                                                                type="checkbox"
                                                                value="false"
                                                                <?php echo $this->defaults->deleteSsAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
                                                    <div class="control-group error" id="deletesssure">
                                                            <label
                                                                    class="control-label error"
                                                                    id="lbldeletesssure">
                                                                    Ja, ik ben zeker
                                                            </label>
                                                            <div class="controls">
                                                                <input
                                                                    id="blndeletesssure"
                                                                    name="deleteSsAccountSure"
                                                                    type="checkbox"
                                                                    value="false">
                                                            </div>
                                                    </div>
							<?php
                            }
                            if ($this->multipleAccountsSelected || $this->hasSsAccountEnabled || $this->manageTemplate)
                           {?>
                                                    <div class="control-group">
							<label class="control-label" for="blnSsDisable">
								Account deactiveren
                                                        </label>
                                                        <div class="controls">
								<input
									name="disableSsAccount"
									id="blnSsDisable"
									type="checkbox"
									<?php echo $this->defaults->disableSsAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
							<?php
                           }
                           if($this->multipleAccountsSelected || !$this->hasSsAccountEnabled && $this->hasSsAccount || $this->manageTemplate)
                           {?>
							<div class="control-group">
                                                            <label class="control-label" for="blnSsEnable">
								Account activeren
                                                            </label>
                                                            <div class="controls">
								<input
									name="enableSsAccount"
									id="blnSsEnable"
									type="checkbox"
									<?php echo $this->defaults->enableSsAccount ? "checked='checked'" : "" ?>>
                                                            </div>
                                                        </div>
							<?php }?>
						</div>
        
					</div>
				</section>

				<section id="googleapps">
					<div class="page-header">
						<h1>
							Google <small>taken</small>
						</h1>
					</div>

					<div class="row">
						<div class="span12">
							<?php if ($this->multipleAccountsSelected || !$this->hasGappAccount || $this->manageTemplate)
                                                {?>
                                                    <div class="control-group">
                                                        <label class="control-label" for="createGappAccount">    
                                                                Account maken
                                                        </label>
                                                        <div class="controls">
                                                            <input
                                                                name="createGappAccount"
                                                                id="createGappAccount"
                                                                type="checkbox"
                                                                value="true"
                                                                <?php echo $this->defaults->createGappAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
                                                    
							<?php 
                                                }
                                                if ($this->multipleAccountsSelected || $this->hasGappAccount || $this->manageTemplate)
                            {?>
                                                    <div class="control-group">
                                                        <label class="control-label" for="blnDeleteGapp">    
                                                                Account verwijderen
                                                        </label>
                                                        <div class="controls">
                                                            <input
                                                                name="deleteGappAccount"
                                                                id="blnDeleteGapp"
                                                                type="checkbox"
                                                                value="false"
                                                                <?php echo $this->defaults->deleteGappAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
                                                    <div class="control-group error" id="deletegappsure">
                                                            <label
                                                                    class="control-label error"
                                                                    id="lbldeletegappsure">
                                                                    Ja, ik ben zeker
                                                            </label>
                                                            <div class="controls">
                                                                <input
                                                                    id="blndeletegappsure"
                                                                    name="deleteGappAccountSure"
                                                                    type="checkbox"
                                                                    value="false">
                                                            </div>
                                                    </div>
							<?php
                            }
                            if ($this->multipleAccountsSelected || $this->hasGappAccountEnabled || $this->manageTemplate)
                           {?>
                                                    <div class="control-group">
							<label class="control-label" for="blnGappDisable">
								Account deactiveren
                                                        </label>
                                                        <div class="controls">
								<input
									name="disableGappAccount"
									id="blnGappDisable"
									type="checkbox"
									<?php echo $this->defaults->disableGappAccount ? "checked='checked'" : "" ?>>
                                                        </div>
                                                    </div>
							<?php
                           }
                           if($this->multipleAccountsSelected || !$this->hasGappAccountEnabled  || $this->manageTemplate)
                           {?>
							<div class="control-group">
                                                            <label class="control-label" for="blnGappEnable">
								Account activeren
                                                            </label>
                                                            <div class="controls">
								<input
									name="enableGappAccount"
									id="blnGappEnable"
									type="checkbox"
									<?php echo $this->defaults->enableGappAccount ? "checked='checked'" : "" ?>>
                                                            </div>
                                                        </div>
							<?php }?>
						</div>
					</div>
				</section>
			</div>
			<div class="modal-footer">
				<a
					href="#"
					class="btn"
					data-dismiss="modal">Annuleren</a>
				<button
					class="btn btn-primary"
					id="submitBtn"
					name="submitBtn"
					type="submit"
					value="<?php 
                                            if($this->manageTemplate)
                                                echo ($this->addtemplate) ? "addTemplate" : "editTemplate";
                                            else
                                                echo "addTasks"
                                        ?>">Uitvoeren</button>
			</div>
		</div>
	</div>
	
	

</form>
